package com.mjlf.t.heartinserct.server;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

/**
 * @ClassName HeartServerInitHandler
 * @auther mjlf
 * @Date 2019/9/18 11:32
 * @Description TODO
 */
public class HeartServerInitHandler extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline()

                //心跳检查处理， 第一个参数表示50秒为检查到读数据
                //第二个参数表示45秒未检查到写数据
                //第三个参数表示60秒没有检查到读写数据
                .addLast(new IdleStateHandler(50, 45, 60))
                .addLast(new HeartServerHandler());
    }
}
